package com.ycfmedical.bed.ui.fragment;

import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.SearchView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.ycfmedical.bed.R;
import com.ycfmedical.bed.adapter.PhysicianChargeAdapter;
import com.ycfmedical.bed.local.DataManager;
import com.ycfmedical.bed.local.entity.PhysicianChargeMsg;
import com.ycfmedical.bed.present.PhysicianChargePresenter;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;
import cn.droidlover.xdroidmvp.mvp.XLazyFragment;
import cn.droidlover.xrecyclerview.XRecyclerView;

/**
 * Created by yf on 2017-03-27.
 */

public class PhysicianChargeFragment extends XLazyFragment<PhysicianChargePresenter> {

    @BindView(R.id.physician_recyclerView)
    XRecyclerView physicianRecyclerView;
    Unbinder unbinder;
    @BindView(R.id.physician_search)
    SearchView physicianSearch;
    private PhysicianChargeAdapter physicianAdapter;

    @Override
    public void initData(Bundle savedInstanceState) {
        initSearchView();
        initRecyclerView();
        if(null!=DataManager.getInstance().getUser().getId()){

            getP().loadData(DataManager.getInstance().getUser().getId());
        }
    }

    private void initRecyclerView() {
        physicianAdapter = new PhysicianChargeAdapter(getContext());
        physicianRecyclerView.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false));
        physicianRecyclerView.setAdapter(physicianAdapter);
        //new ViLayoutManager()
    }

    /**
     * 搜索框
     */
    private void initSearchView() {
        //TODO　搜索医嘱
    }

    public void showData(List<PhysicianChargeMsg> physicianMsgList) {
        physicianAdapter.setData(physicianMsgList);
        physicianAdapter.notifyDataSetChanged();
    }

    @Override
    public int getLayoutId() {
        return R.layout.fragment_physiciancharge;
    }

    @Override
    public PhysicianChargePresenter newP() {
        return new PhysicianChargePresenter();
    }




}
